package cn.bluemobi.platform.utils;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;

/**
 * 
 * @author lvxh
 * 
 */
public class CommonUtils {

    /**
     * 获取指定格式的当前日期
     * 
     * @param fmt
     * @return
     */
    public static String currentDate(String fmt) {
        String date = "";
        SimpleDateFormat sdf = new SimpleDateFormat(fmt);
        date = sdf.format(new Date());
        return date;
    }

    /**
     * 生成随机数
     * 
     * @param length
     * @return
     */
    public static String createNumber(int length) {
        Random random = new Random();
        String result = "";
        for (int i = 0; i < length; i++) {
            result += random.nextInt(10);
        }
        return result;
    }
}